﻿#region LGPL
/************************************************************************************/
/* Fireball.Windows.Forms a controls library for windows forms
 * 
 * Copyright (C) 2009 Sebastian Faltoni
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the 
 * Free Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
 * for more details.
 * You should have received a copy of the GNU Lesser General Public License along
 * with this library; if not, write to the Free Software Foundation, Inc., 59 
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * Signature of Sebastian Faltoni, 2 Febbraio 2009
 * Sebastian Faltoni, President of Orangebit
 * 
 ***********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Orangebit.Windows.Forms
{
    public class ScrollableControl : Control
    {
        public ScrollableControl()
        {
            //base.VerticalScroll.
        }

        private bool canScrollVertically = false;
        private bool canScrollHorizontally = false;
        //private VScrollBar verticallScrollBar = null;
        //private HScrollBar horizontalScrollBar = null;

        public bool CanScrollVertically
        {
            get
            {
                return canScrollVertically;
            }
            set
            {
                canScrollVertically = value;
                this.VerticalScroll.Visible = value;
            }
        }

        public override bool AutoScroll
        {
            get
            {
                return false;
            }
            set
            {
             
            }
        }


        public bool CanScrollHorizontally
        {
            get
            {
                return canScrollHorizontally;
            }
            set
            {
                canScrollHorizontally = value;
                this.HorizontalScroll.Visible = value;
            }
        }

        //public VScrollBar VerticalScrollBar
        //{
        //    get
        //    {
        //        return verticallScrollBar;
        //    }
        //}

        //public HScrollBar HorizontalScrollBar
        //{
        //    get
        //    {
        //        return horizontalScrollBar;
        //    }
        //}

        //private Rectangle displayRectangle = Rectangle.Empty;
        //public override System.Drawing.Rectangle DisplayRectangle
        //{
        //    get
        //    {
        //        if (displayRectangle == Rectangle.Empty)
        //            return new Rectangle(0, 0, this.Width, this.Height);
        //        return displayRectangle;
        //    }
        //}


        //protected override void OnLayout(LayoutEventArgs levent)
        //{
        //    base.OnLayout(levent);
        //    setScrollBars();
        //}

        //override  

        //private void setScrollBars()
        //{
        //    verticallScrollBar.Top = 0;
        //    verticallScrollBar.Left = this.Width - this.verticallScrollBar.Width;
        //    verticallScrollBar.Height = this.Height - 1;
        //    horizontalScrollBar.Top = this.Height - horizontalScrollBar.Height;
        //    horizontalScrollBar.Left = 0;
        //    horizontalScrollBar.Width = this.Width - 1;

        //    int width = this.Width;
        //    int height = this.Height;

        //    if (this.CanScrollVertically)
        //    {
        //        this.Width -= this.HorizontalScrollBar.Width;
        //    }
        //    if (this.CanScrollHorizontally)
        //    {
        //        this.Height -= this.VerticalScrollBar.Height;
        //    }
        //    displayRectangle = new Rectangle(0, 0, width, height);
        //}

        //public ScrollableControl()
        //{
        //    verticallScrollBar = new VScrollBar();
        //    this.Controls.Add(verticallScrollBar);
        //    horizontalScrollBar = new HScrollBar();
        //    this.Controls.Add(horizontalScrollBar);
        //}
    }
}
